<?php
require './common/utils.php';
$database = require './common/Database.php';

$id = $_POST['id'];
// $id = $_request['id'];

$product = [];
foreach ($database['products'] as $item) {
    if ($item['id'] == $id) {
        $product = $item;
        $product['cover']=parseImgUrl($product['cover']);
        break;
    }
}

$ret = empty($product) ? [
    'stat' => 0,
    'msg' => '找不到该商品！',
    'data' => null,
] : [
    'stat' => 1,
    'msg' => '',
    'data' => $product,
];

echo json_encode($ret);
